#ifndef __METAINFO_APE_H
#define __METAINFO_APE_H

#include <stdio.h>
#include <glib.h>

#include "common.h"
#include "metainfo.h"


struct ape_tag;
gboolean         ape_tag_detect(const gchar *path, 
								gboolean *atend, 
								gboolean *haveid3);

/* @version: now there are only two versions, 1000(1.000) and
   2000(2.00), if @version if less than 2000, 1000 is taken, or 2000
   is taken  */
struct ape_tag  *ape_tag_new(gint version);
struct ape_tag  *ape_tag_load(const gchar *path);
gboolean         ape_tag_save(struct ape_tag *tag, const gchar *path);
void             ape_tag_free(struct ape_tag *tag);

/* NOTE: all returned string are NOT nul terminated, and shuld not be changed  */
const gchar     *ape_tag_read_tag(struct ape_tag *tag, 
								  const gchar *key, 
								  gint *len);
/* @len: length of value, -1 if value is nul terminated */
gboolean         ape_tag_write_tag(struct ape_tag *tag, 
								   const gchar *key, 
								   const gchar *value, 
								   gint len);






/* glue code for metainfo */
gboolean ape_probe(FILE *fp);
gboolean ape_read(FILE *fp, struct meta *meta);
gboolean ape_write(FILE *fp, struct meta *meta);
gchar   *ape_get_property(struct meta *meta, const gchar *property);
gboolean ape_set_property(struct meta *meta, const gchar *property, const gchar *value);
gboolean ape_release(struct meta *meta);

#endif /* __METAINFO_APE_H */

